package cn.wolfcode.crm.service.imp;

import cn.wolfcode.crm.domain.DataItems;
import cn.wolfcode.crm.mapper.DataItemsMapper;
import cn.wolfcode.crm.service.IDataItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataItemsServiceImpl implements IDataItemsService {
    @Autowired
    private DataItemsMapper dataItemsMapper;

    @Override
    public List<DataItems> selectAll() {
        return dataItemsMapper.selectAll();
    }

    @Override
    public void saveOrUpdate(DataItems entity) {
        if (entity.getId() != null) {
            dataItemsMapper.updateByPrimaryKey(entity);
        }else {
            dataItemsMapper.insert(entity);
        }
    }

    @Override
    public void delete(Long id) {
        dataItemsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public DataItems get(Long id) {
        return dataItemsMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<DataItems> list() {
        return dataItemsMapper.selectAll();
    }

}
